﻿// Form that when "submitted" performs an action without submitting to the server
define([
    'Wjs/ui/widgets/forms/Form'
],
function () {
    'use strict';

    return Wjs.defineOnce({

        type: 'LocalForm',

        internal: {

            base: Wjs.getType('Form')
        },

        submit: function (bypassBeforeSubmit) {
            var data;

            if (this.getBase().submit.call(this, bypassBeforeSubmit) === false) {

                return; // Do not submit
            }

            if (this.submitHandler) {

                data = this.serialize();

                this.submitHandler(data); // The data is the serialized form

                this.acceptChanges(); // Set the fields as not modified
            }
        }

    });

});
